export function createStore (reducer, preloadedState, enhancer) {

      // 增强dispatch函数 start
  if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
    enhancer = preloadedState
    preloadedState = undefined
  }
    let subscribe_fns = new Set()
    let state = preloadedState
    return {
        getState () {
            return state
        },
        subscribe (fn) {
            subscribe_fns.add(fn)
        },
        dispatch (action) {
            state = reducer(state, action)
            for(let fn of subscribe_fns) {
                fn()
            }
        }
    }
} 